package demo1;

import java.util.Arrays;

public class Test1 {
    //模拟冒泡排序写
    public static void mySort(Comparable[] comparables) {
        for (int i = 0; i < comparables.length-1; i++) {
            for (int j = 0; j < comparables.length-1-i; j++) {
                if(comparables[j].compareTo(comparables[j+1]) > 0) {
                    Comparable tmp = comparables[j];
                    comparables[j] = comparables[j+1];
                    comparables[j+1] = tmp;
                }
            }
        }
    }

    public static void main(String[] args) {
        Student student1 = new Student("zhangsan", 10);
        Student student2 = new Student("lisi", 19);
        //System.out.println(student1.compareTo(student2));
        Student[] students = new Student[]{
                new Student("zhangsan", 10),
                new Student("lisi", 19),
                new Student("wangwu", 8)};
        //students[0] = new Student("zhangsan", 10);
        //System.out.println(students[0]);
        System.out.println("排序前："+Arrays.toString(students));
        Arrays.sort(students);
        //mySort(students);
        System.out.println("排序后："+Arrays.toString(students));
    }
}
